package com.qingcheng.service.impl;

/**
 * @author yangjun
 * 2019/7/11
 * 15:53
 */

import org.apache.http.HttpHost;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestClientBuilder;
import org.elasticsearch.client.RestHighLevelClient;

/**
 * 连接elasticsearch高级客户端工厂类
 */

public class RestClientFactory {
    public static RestHighLevelClient getRestHighLevelClient(String hostName,int port){
        HttpHost httpHost=new HttpHost(hostName,port,"http");
        RestClientBuilder builder=RestClient.builder(httpHost);//rest构建器
        return new RestHighLevelClient(builder);//高级客户端对象(连接)

    }
}
